package com.gxg.newdemo1.mynewdamo1.channel.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class SQLHelper extends SQLiteOpenHelper {
	public static final String DB_NAME = "database.db";// 数据库名称
	public static final int VERSION = 1;

	public static final String TABLE_CHANNEL = "channel";//数据表


	public static final String RID = "rid";//
	public static final String SID = "sid";//
	public static final String NAME = "name";
	public static final String PIC = "pic";
	public static final String SELECTED = "selected";
	public static final String IMG = "img";//
	public static final String ISCHANGE = "ischange";//是否可改
	public static final String UAD = "uad";//栏目方向
	public static final String PUSHNUM = "PushNum";
	public static final String TYPE = "type";
	public static final String CHNLURL = "url";
	private Context context;
	public SQLHelper(Context context) {
		super(context, DB_NAME, null, VERSION);
		this.context = context;
	}

	public Context getContext(){
		return context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO 创建数据库后，对数据库的操作
		String sql = "create table if not exists "+TABLE_CHANNEL +
				"(_id INTEGER PRIMARY KEY AUTOINCREMENT, "
				+ RID + " INTEGER ," +
				" " + NAME + " TEXT , "
				+ IMG + " INTEGER , "
				+ TYPE + " INTEGER , "
				+ PIC + " TEXT , "
				+ ISCHANGE + " INTEGER , "
				+ UAD + " INTEGER , "
				+ PUSHNUM + " INTEGER , "
				+ SID + " TEXT , "
				+CHNLURL + " TEXT , "
				+ SELECTED + " SELECTED)";
		Log.e("sql",sql);
		db.execSQL(sql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO 更改数据库版本的操作
		onCreate(db);
	}

}
